use cgmath::prelude::*;
use cgmath::{Point3, Vector3, Matrix4, Quaternion};

pub struct Camera {
    position: Point3<f32>,
    front_direction: Vector3<f32>,
    up_direction:Vector3<f32>
}

impl Camera {
    pub fn new(in_position: Point3<f32>, in_front_direction: Vector3<f32>, in_up_direction: Vector3<f32>) -> Self {
        Camera {position: in_position, front_direction: in_front_direction, up_direction: in_up_direction}
    }

    pub fn view_matrix_recalculation(&self) -> Matrix4<f32> {
        Matrix4::look_to_rh(self.position, self.front_direction, self.up_direction)
    }

    pub fn rotate_along_up(&mut self, angle: f32) -> &mut Self {
        self.front_direction = Quaternion::from_sv((angle / 2.0f32).cos(),self.up_direction * (angle / 2.0f32).sin()).rotate_vector(self.front_direction);
        self
    }

    pub fn move_along_direction(&mut self, distance: f32) -> &mut Self {
        self.position = self.position + self.front_direction * distance;
        self
    }
}



